package second.group.bering.parking_system

import second.group.bering.parking_system.model.Car
import spock.lang.Specification
import spock.lang.Unroll
/**
 *
 * SmartParkingBoyTest
 *
 * @author Burgess Li
 * @date 8/24/2018 1:51 PM
 * @version 1.0
 *
 */
class SuperParkingBoyTest extends Specification {


    @Unroll
    def 'should return park details: #PARK_ID when input car: #CAR_NUMBER, parks: #PARKS'() {

        given:
        SuperParkingBoy superParkingBoy = new SuperParkingBoy()
        PARKS.each { parkId, parkSize ->
            superParkingBoy.addPark(new Park(id: parkId, size: parkSize))
            CURRENT_PARKING_CARS[parkId].each { superParkingBoy.parking(new Car(number: it)) }
        }

        expect:
        superParkingBoy.parking(new Car(number: CAR_NUMBER)) == PARK_ID

        where:
        PARKS                   |   CURRENT_PARKING_CARS                                     |   CAR_NUMBER      |     PARK_ID
        ['P1': 10, 'P2': 20]    |   ['P1': ['A110', 'A120'], 'P2': ['A210', 'A220'] ]        |   'A230'          |     'P2'
        ['P1': 10, 'P2': 10]    |   ['P1': ['A110', 'A120'], 'P2': ['A210', 'A220'] ]        |   'A130'          |     'P1'
        ['P1': 10, 'P2': 10]    |   ['P1': ['A110', 'A120'], 'P2': ['A210', 'A220'] ]        |   'A120'          |     null
        ['P1': 2, 'P2': 2]      |   ['P1': ['A110', 'A120'], 'P2': ['A210', 'A220'] ]        |   'A130'          |     null

    }


}
